from django.db import models
from base import *
from object_models import *
from resource_models import *
from protocol_models import *
from experiment_models import *

__all__ = ["SERVICE_TYPES", "WebService", "AccessibleExperiment"]

SERVICE_TYPES = (("download", "Represents a service that allows one to download a snapshot."),
                ("cutout", "Represents a SimDAP service that defines a cut-out operation on an existing snapshot."),
                ("gridding", "Represents a SimDAP service that defines a (re)gridding operation on an existing snapshot."),
                ("clusterfinder", "Represents a SimDAP service that defines a cluster-finder operation on an existing snapshot, supposedly of an N-body simulation."),
                ("visualisation", "Represents a SimDAP service that defines a visualisation operation on an existing snapshot, producing a 2 dimensional grid."),
                ("custom", "Thie represents a general, unspecified online operation on a simulation. It may be of any kind, no restriction on interface."))

class WebService(Resource):
    _collection_sets = []
    element_name = 'aWebService'
    baseurl = models.URLField(blank=True, null=True)
    registryid = models.URLField(null=True)
    description = models.TextField(blank=True)
    type = models.CharField(max_length=256, choices=SERVICE_TYPES, 
                            default='download')

class AccessibleExperiment(MetadataObject):
    _collection_sets = []
    service = models.ForeignKey(WebService)
    experiment = models.ForeignKey(Experiment)
    _container_field = "service_id"
    WebService._collection_sets.append('accessibleexperiment_set')
